package com.dji.sample.manage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dji.sample.manage.dao.DevicePlayLineCacheMapper;
import com.dji.sample.manage.model.entity.DevicePlayLineCacheEntity;
import com.dji.sample.manage.service.DevicePlayLineCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yjt
 * @date 2022-10-08
 * @description:
 */
@Service
public class DevicePlayLineCacheServiceImpl implements DevicePlayLineCacheService {
    @Autowired
    DevicePlayLineCacheMapper devicePlayLineCacheMapper;

    @Override
    public void save(DevicePlayLineCacheEntity devicePlayLineCacheEntity) {
        devicePlayLineCacheMapper.insert(devicePlayLineCacheEntity);
    }

    @Override
    public DevicePlayLineCacheEntity findByLineId(Long lineId) {
        return devicePlayLineCacheMapper.selectOne(new LambdaQueryWrapper<DevicePlayLineCacheEntity>().eq(DevicePlayLineCacheEntity::getLineId,lineId).last("limit 1"));
    }

    @Override
    public DevicePlayLineCacheEntity findByTaskId(Long taskId) {
        return devicePlayLineCacheMapper.selectOne(new LambdaQueryWrapper<DevicePlayLineCacheEntity>().eq(DevicePlayLineCacheEntity::getTaskId,taskId).last("limit 1"));
    }
}
